<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>首页 - 光年(Light Year Admin)后台管理系统模板</title>
  <link rel="icon" href="favicon.ico" type="image/ico">
  <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
  <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
  <meta name="author" content="yinqi">
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/materialdesignicons.min.css" rel="stylesheet">
  <link href="css/style.min.css" rel="stylesheet">
  <link href="css/index.css" rel="stylesheet">

  
  <!-- JQuery -->
  <link href="js/jquery.js" rel="stylesheet">
  <script src=""></script>

  <title>默认点标记</title>
  <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />

  <style>
    html,
    body,
    #container {
      height: 100%;
      width: 100%;
    }

    .amap-icon img,
    .amap-marker-content img {
      width: 25px;
      height: 34px;
    }

    .marker {
      position: absolute;
      top: -20px;
      right: -118px;
      color: #fff;
      padding: 4px 10px;
      box-shadow: 1px 1px 1px rgba(10, 10, 10, .2);
      white-space: nowrap;
      font-size: 12px;
      font-family: "";
      background-color: #25A5F7;
      border-radius: 3px;
    }

    .input-card {
      width: 18rem;
      z-index: 170;
    }

    .input-card .btn {
      margin-right: -0.2rem;
    }

    .input-card .btn:last-child {
      margin-right: 0;
    }
  </style>
</head>

<body>
  <div class="lyear-layout-web " onload="showalldata()">
    <script>
      function showalldata() {

      }
    </script>
    <div class="lyear-layout-container">
      <!--左侧导航-->
      <aside class="lyear-layout-sidebar">

        <!-- logo -->
        <div id="logo" class="sidebar-header">
          <a href="index.html"><img src="images/logo.png" style="height: 20px;" title="LightYear" alt="LightYear" /></a>
        </div>
        <div class="lyear-layout-sidebar-scroll">

          <nav class="sidebar-main">
            <ul class="nav nav-drawer">
              <li class="nav-item active"> <a href="index.html"><i class="mdi mdi-home"></i> 首页</a> </li>


              <li class="nav-item nav-item-has-subnav">
                <a href="javascript:void(0)"><i class="mdi mdi-file-outline"></i> 报警监测</a>
                <ul class="nav nav-subnav">

                </ul>
              </li>
              <li class="nav-item nav-item-has-subnav">
                <a href="javascript:void(0)"><i class="mdi mdi-language-javascript"></i> 工人现场分布情况</a>
                <ul class="nav nav-subnav">

                </ul>
              </li>
              <li class="nav-item nav-item-has-subnav">
                <a href="javascript:void(0)"><i class="mdi mdi-menu"></i> 菜单</a>
                <ul class="nav nav-subnav">
                  <li> <a href="#!">一级菜单</a> </li>
                  <li class="nav-item nav-item-has-subnav">
                    <a href="#!">一级菜单</a>
                    <ul class="nav nav-subnav">
                      <li> <a href="#!">二级菜单</a> </li>
                      <li class="nav-item nav-item-has-subnav">
                        <a href="#!">二级菜单</a>
                        <ul class="nav nav-subnav">
                          <li> <a href="#!">三级菜单</a> </li>
                          <li> <a href="#!">三级菜单</a> </li>
                        </ul>
                      </li>
                    </ul>
                  </li>
                  <li> <a href="#!">一级菜单</a> </li>
                </ul>
              </li>
            </ul>
          </nav>


        </div>

      </aside>
      <!--End 左侧导航-->

      <!--头部信息-->
      <header class="lyear-layout-header">

        <nav class="navbar navbar-default">
          <div class="topbar">

            <div class="topbar-left">
              <div class="lyear-aside-toggler">
                <span class="lyear-toggler-bar"></span>
                <span class="lyear-toggler-bar"></span>
                <span class="lyear-toggler-bar"></span>
              </div>
              <span class="navbar-page-title"> 后台首页 </span>
            </div>

            <ul class="topbar-right">
              <li class="dropdown dropdown-profile">
                <a href="javascript:void(0)" data-toggle="dropdown">
                  <!-- <img class="img-avatar img-avatar-48 m-r-10" src="images/users/avatar.jpg" alt="笔下光年" /> -->
                  <span>功能1 <span class="caret"></span></span>
                  <span>功能2 <span class="caret"></span></span>
                  <span>功能3 <span class="caret"></span></span>
                  <span>功能4 <span class="caret"></span></span>
                  <span>功能5 <span class="caret"></span></span>
                </a>
                <!-- <ul class="dropdown-menu dropdown-menu-right">
                <li> <a href="lyear_pages_profile.html"><i class="mdi mdi-account"></i> 个人信息</a> </li>
                <li> <a href="lyear_pages_edit_pwd.html"><i class="mdi mdi-lock-outline"></i> 修改密码</a> </li>
                <li> <a href="javascript:void(0)"><i class="mdi mdi-delete"></i> 清空缓存</a></li>
                <li class="divider"></li>
                <li> <a href="lyear_pages_login.html"><i class="mdi mdi-logout-variant"></i> 退出登录</a> </li>
              </ul> -->
              </li>
              <!--切换主题配色-->
              <li class="dropdown dropdown-skin">
                <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
                <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                  <li class="drop-title">
                    <p>主题</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">

                      <input type="radio" name="site_theme" value="default" id="site_theme0" checked;>
                      <label for="site_theme0"></label>
                    </span>
                    <span>
                      <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                      <label for="site_theme_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                      <label for="site_theme_3"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>LOGO</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                      <label for="logo_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                      <label for="logo_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                      <label for="logo_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                      <label for="logo_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                      <label for="logo_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                      <label for="logo_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                      <label for="logo_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                      <label for="logo_bg_8"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>头部</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                      <label for="header_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                      <label for="header_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                      <label for="header_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                      <label for="header_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                      <label for="header_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                      <label for="header_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                      <label for="header_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                      <label for="header_bg_8"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>侧边栏</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                      <label for="sidebar_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                      <label for="sidebar_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                      <label for="sidebar_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                      <label for="sidebar_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                      <label for="sidebar_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                      <label for="sidebar_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                      <label for="sidebar_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                      <label for="sidebar_bg_8"></label>
                    </span>
                  </li>
                </ul>
              </li>
              <!--切换主题配色-->
            </ul>

          </div>
        </nav>

      </header>
      <!--End 头部信息-->

      <!--页面主要内容-->
      <main class="lyear-layout-content">

        <div class="container-fluid">
          <div class="row">





          </div>

          <div class="row"></div>

          <style>
            .btn .btn-w-md btn-round btn-info {
              height: 100px;
              width: 150px;
              position: absolute;
              top: 15px;
            }
          </style>

          <div class="col-lg-12" style="height: 894px; position: relative;">

            <div id="container"></div>
            <div>

            </div>


            <style>

            </style>
            <div class="input-card">
              <label style="color:grey">功能</label>
              <div class="input-item">
                <input id="addMarker" type="button" class="btn" onclick="addMarker()" value="添加人员">
                <input id="updateMarker" type="button" class="btn" onclick="updateIcon()" value="更新人员">
              </div>
              <div class="input-item">
                <input id="clearMarker" type="button" class="btn" onclick="clearMarker()" value="删除人员">
                <input id="updateMarker" type="button" class="btn" onclick="updateContent()" value="更新信息">
              </div>
              <!-- 轨迹回放功能 -->
              <h4>轨迹回放控制</h4>
              <div class="input-item">
                <input type="button" class="btn" value="开始动画" id="start" onclick="startAnimation()" />
                <input type="button" class="btn" value="暂停动画" id="pause" onclick="pauseAnimation()" />
              </div>
              <div class="input-item">
                <input type="button" class="btn" value="继续动画" id="resume" onclick="resumeAnimation()" />
                <input type="button" class="btn" value="停止动画" id="stop" onclick="stopAnimation()" />
              </div>
              <!-- 轨迹回放功能结束 -->
            </div>
          </div>





        </div>

      </main>
      <!--End 页面主要内容-->

    </div>
  </div>

  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
  <script type="text/javascript" src="js/main.min.js"></script>
  <script type="text/javascript"
    src="https://webapi.amap.com/maps?v=1.4.15&key=c057813487caa294fe163311c2ec6bdb&plugin=AMap.PolyEditor">
    </script>
  <script type="text/javascript">

    // 实例化地图,并设置中心点
    var marker, map = new AMap.Map("container", {
      resizeEnable: true,
      center: [120.63520638241431, 31.425001399727474],
      zoom: 14
    });



    // 实例化点标记
    function addMarker() {
      marker = new AMap.Marker({
        icon: "./images/employee_head_man.png",
        position: [120.63520638241431, 31.425001399727474],
        offset: new AMap.Pixel(0, 0)
      });
      marker.setMap(map);
    }

    function updateIcon() {

      marker.setIcon("./images/employee_head_man.png")
    }

    function updateContent() {

      if (!marker) {
        return;
      }

      // 自定义点标记内容
      var markerContent = document.createElement("div");

      // 点标记中的图标
      var markerImg = document.createElement("img");
      markerImg.className = "markerlnglat";
      markerImg.src = './images/employee_head_man.png';
      markerContent.appendChild(markerImg);

      // 点标记中的文本
      var markerSpan = document.createElement("span");
      markerSpan.className = 'marker';
      markerSpan.innerHTML = "Hi，我被更新啦！";
      markerContent.appendChild(markerSpan);

      marker.setContent(markerContent); //更新点标记内容
      marker.setPosition([120.63520638241431, 31.425001399727474]); //更新点标记位置
    }

    // 清除 marker
    function clearMarker() {

      if (marker) {
        marker.setMap(null);
        marker = null;
      }
    }


    //设置点标注的文本标签


    // // 设置鼠标划过点标记显示的文字提示
    // marker.setTitle('我是marker的title');

    // // 设置label标签
    // // label默认蓝框白底左上角显示，样式className为：amap-marker-label
    // marker.setLabel({
    //   offset: new AMap.Pixel(0, 0),  //设置文本标注偏移量
    //   content: "<div class='info'>liuyang</div>", //设置文本标注内容
    //   direction: 'right' //设置文本标注方位
    // });


    // 定位示例
    // 模拟坐标点数据
    var list = [
      {
        name: '刘阳1',
        lon: 120.63520638241431,
        lat: 31.435001399727474
      },
      {
        name: '刘阳2',
        lon: 120.63520638241431,
        lat: 31.445001399727474
      },
      {
        name: '刘阳3',
        lon: 120.63520638241431,
        lat: 31.455001399727474
      },
      {
        name: '刘阳4',
        lon: 120.63520638241431,
        lat: 31.465001399727474
      }
    ]



    // 路线示例
    // 模拟模拟路线数据
    var path = [
      [120.63520638241431, 31.435001399727474],
      [120.63520638241431, 31.445001399727474],
      [120.63520638241431, 31.455001399727474],
      [120.63520638241431, 31.465001399727474]
    ]


    var polyline = new AMap.Polyline({
      path: path,
      isOutline: true,
      outlineColor: '#ffeeff',
      borderWeight: 3,
      strokeColor: "#3366FF",
      strokeOpacity: 1,
      strokeWeight: 6,
      // 折线样式还支持 'dashed'
      strokeStyle: "solid",
      // strokeStyle是dashed时有效
      strokeDasharray: [10, 5],
      lineJoin: 'round',
      lineCap: 'round',
      zIndex: 50,
    })

    polyline.setMap(map)
    // 缩放地图到合适的视野级别
    map.setFitView([polyline])

    var polyEditor = new AMap.PolyEditor(map, polyline)

    polyEditor.on('addnode', function (event) {
      log.info('触发事件：addnode')
    })

    polyEditor.on('adjust', function (event) {
      log.info('触发事件：adjust')
    })

    polyEditor.on('removenode', function (event) {
      log.info('触发事件：removenode')
    })

    polyEditor.on('end', function (event) {
      log.info('触发事件： end')
      // event.target 即为编辑后的折线对象
    })



    //轨迹回放功能
    // 坐标点集合
    var marker, lineArr = [
      [120.63520638241431, 31.435001399727474],
      [120.63520638241431, 31.445001399727474],
      [120.63520638241431, 31.455001399727474],
      [120.63520638241431, 31.465001399727474],
      [120.63520638241431, 31.475001399727474],
      [120.63520638241431, 31.485001399727474],
      [120.63520638241431, 31.495001399727474],
      [120.63520638241431, 31.505001399727474],
      [120.63520638241431, 31.515001399727474],
      [120.63520638241431, 31.525001399727474],
      [120.63520638241431, 31.535001399727474],
      [120.63520638241431, 31.545001399727474],
    ]


    marker = new AMap.Marker({
      map: map,
      position: [120.63520638241431, 31.435001399727474],
      icon: "./images/employee_head_man.png",
      offset: new AMap.Pixel(0, 0),
      autoRotation: true,
      // angle: -90,
    });


    // 绘制轨迹
    var polyline = new AMap.Polyline({
      map: map,
      path: lineArr,
      showDir: true,
      strokeColor: "#28F",  //线颜色
      // strokeOpacity: 1,     //线透明度
      strokeWeight: 6,      //线宽
      // strokeStyle: "solid"  //线样式
    });

    var passedPolyline = new AMap.Polyline({
      map: map,
      // path: lineArr,
      strokeColor: "#AF5",  //线颜色
      // strokeOpacity: 1,     //线透明度
      strokeWeight: 6,      //线宽
      // strokeStyle: "solid"  //线样式
    });


    // 轨迹生成函数
    // marker.on('moving', function (e) {
    //     passedPolyline.setPath(e.passedPath);
    // });

    // map.setFitView();

    function startAnimation() {
      marker.moveAlong(lineArr, 200);
    }

    function pauseAnimation() {
      marker.pauseMove();
    }

    function resumeAnimation() {
      marker.resumeMove();
    }

    function stopAnimation() {
      marker.stopMove();
    }


    
    list.forEach(element => {
      marker = new AMap.Marker({
        icon: "./images/employee_head_man.png",
        position: [element.lon, element.lat],
        offset: new AMap.Pixel(0, 0)
      });
      marker.setMap(map);
      marker.setTitle('我是marker的title');
      marker.setLabel({
        offset: new AMap.Pixel(0, 0),  //设置文本标注偏移量
        content: "<div class='info' style='min-width: 13rem'>员工姓名:" + element.name + "</div>", //设置文本标注内容
        direction: 'right' //设置文本标注方位
      });
      marker.on('moving', function (e) {
        passedPolyline.setPath(e.passedPath);
      });

      map.setFitView();

    });
  </script>
</body>

</html>